﻿$(document).ready(function () {
    //setActive();
    setClick();
});

function setActive() {
    aObj = $("#navigation a");
    for (i = 0; i < aObj.length; i++) {
        if (document.location.href.indexOf(aObj[i].href) >= 0) {
            $(aObj[i]).addClass("active");
        }
    }
}

function setClick() {
    $("#popupBg").click(function () {
        $(".pop").fadeOut();
    });
    
    $("#add").click(function () {
        $("#searchUl").css({ "display": "none" });
        if ($("#crUl").css("display") == "block") {
            $("#crUl").css({ "display": "none" });
        }
        else {
            $("#crUl").css({ "display": "block" });
        }
    });

    $("#search").click(function () {
        $("#crUl").css({ "display": "none" });
        if ($("#searchUl").css("display") == "block") {
            $("#searchUl").css({ "display": "none" });
        }
        else {
            $("#searchUl").css({ "display": "block" });
        }
    });

    $(".create").click(function () {
        $(".eventContainer").css({ "display": "none" });
        $("#" + this.id.toString().split('_')[1]).fadeIn();
    });

    if (window.location.pathname != undefined) {
        if (window.location.pathname.indexOf("customerDetail") != -1) {
            $("#customerInfo").css({ "display": "block" });
            $("#ctl00_HiddenField_SearchId").val("1");
            $("#ctl00_Button_SearchCustomer").css({ "display": "block" });
        }
    }

    if (window.location.pathname != undefined) {
        if (window.location.pathname.indexOf("customerSearch") != -1) {
            $("#customerList").css({ "display": "block" });
            $("#ctl00_Button_SearchCustomer").css({ "display": "block" });
        }
    }

    if (window.location.pathname != undefined) {
        if (window.location.pathname.indexOf("home") != -1) {
            $("#ctl00_Button_SearchCustomer").css({ "display": "block" });
        }
    }
   
       
    $(".spsearch").click(function () {
        $(".searchButton").css({ "display": "none" });
        $("#ctl00_Button_" + this.id.toString().split('_')[1]).fadeIn();
    });

}

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.search);
    if (results == null)
        return "0";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}
